package com.example.prjbackend.controller;

import com.example.prjbackend.common.core.controller.BaseController;
import com.example.prjbackend.common.core.domain.AjaxResult;
import com.example.prjbackend.common.core.page.TableDataInfo;
import com.example.prjbackend.domain.Bumeng;
import com.example.prjbackend.domain.Category;
import com.example.prjbackend.service.BumengService;
import com.example.prjbackend.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.github.pagehelper.page.PageMethod.startPage;

@CrossOrigin
@RestController
@RequestMapping("/bumeng")
public class BumengController extends BaseController
{
    @Autowired
    BumengService bumengService;
    @PostMapping
    public AjaxResult add(@RequestBody Bumeng bumeng){
        return toAjax(bumengService.add(bumeng));
    }


    @GetMapping
    public TableDataInfo list(Bumeng bumeng)

    {
        startPage();
        List<Bumeng> list=bumengService.list(bumeng);
        //
        Bumeng bm=new Bumeng();
        for(int i=0;i<list.size();i++)
        {
            bm=list.get(i);
            System.out.println(bm);
        }
        return getDataByPage(list);
    }
    @PutMapping
    public AjaxResult edit(@RequestBody Bumeng bumeng){
        return toAjax(bumengService.edit(bumeng));
    }
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(bumengService.delete(ids));
    }


}
